#ifndef __CPPTUTORTCPSOCKETSERVER_H__
#define __CPPTUTORTCPSOCKETSERVER_H__

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#ifdef WIN32
// windows specific
#else
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/errno.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <assert.h>
#include <fcntl.h>
#include <netdb.h>
#include <assert.h>
#include <errno.h>
#include <signal.h>
#include <unistd.h>
#endif

//#define SERVER_PORT 6666
#define BACKLOG 20
#define RECEIVE_BUFF_SIZE 1024*5

class CcppTutorTCPSocketServer
{
	private:
		int iSin_size, iSockfd, iClientfd, iRet, iServerPort, iLogin, m_nReturnStatus, iOpenfd, iWriteNum;
		struct sockaddr_in server_addr;
		struct sockaddr_in client_addr;
		const char *pLogin, *pPasswd, *cLogin, *cPasswd;
		char sLogin[50], sPasswd[50], sReceiveBuff[RECEIVE_BUFF_SIZE], sKeyBoardInput[RECEIVE_BUFF_SIZE], sPrintLogBuff[RECEIVE_BUFF_SIZE], pLogName[100];
        std::string m_strPort, m_strServerLog;
	
	public:
		CcppTutorTCPSocketServer ();
   		CcppTutorTCPSocketServer (std::string);
	   ~CcppTutorTCPSocketServer ();
	    
        int ServerMain();
		int iWriteLogServer (char * pFileName, char * pLogBuff);
};

#endif //__CPPTUTORTCPSOCKETSERVER_H__
